<template>
  <view class="pb-20">
    <video
      v-if="videoUrl"
      :src="encodeURI(videoUrl)"
      :autoplay="true"
      muted
      controls
      controlslist="nodownload noremoteplayback noplaybackrate"
      disablepictureinpicture
      class="video-box"
    ></video>
    <empty v-else />
  </view>
</template>

<script>
import { getVideoUrl } from '@/api/warn-event/index.js'
import config from '@/config'
import Empty from '@/components/cu-empty/index.vue'

export default {
  components: {
    Empty
  },
  data() {
    return {
      videoName: '',
      videoUrl: ''
    }
  },
  onLoad(options) {
    uni.setNavigationBarTitle({
      title: options.name
    })
    getVideoUrl(options.id).then((res) => {
      const { app, stream } = res.data
      this.videoUrl = `${config.staticUrl}/${app}/${stream}.live.mp4`
    })
  }
}
</script>

<style lang="scss" scoped>
.video-box {
  width: 100%;
}
::v-deep .uni-video-controls {
  visibility: hidden;
}
</style>
